//
//  UserPhotoTableViewCell.m
//  UniversalApp
//
//  Created by 志刚杨 on 2018/2/9.
//  Copyright © 2018年 voidcat. All rights reserved.
//

#import "UserPhotoTableViewCell.h"
#import "UIImage+ImageEffect.h"
#import "CYUIScrollView.h"
@implementation UserPhotoTableViewCell
{
    CYUIScrollView *_giftView;
    UILabel *labtitle;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    _giftView = [[CYUIScrollView alloc] init];
    //    _giftView.userInteractionEnabled = NO;
    _giftView.showsHorizontalScrollIndicator = NO;
    _giftView.frame = CGRectMake(5, 20, SCREEN_WIDTH -10, 75);
    [self.contentView addSubview:_giftView];
    
    labtitle = [[UILabel alloc] init];
    labtitle.text = [NSString stringWithFormat:ASLocalizedString(@"小视频")];
    labtitle.font = DEFAULT_FONT(13);
    labtitle.frame = CGRectMake(10, 5, 200, 15);
    [self addSubview:labtitle];
}

-(void)setModel:(UserPageInfoModel *)model
{
    _model = model;
    CGFloat giftwidth = 70;
    float spaing = 3;
    
    _giftView.contentSize = CGSizeMake(giftwidth * model.gift.count, 0);
    _giftView.contentSize = CGSizeMake(giftwidth * 10, 0);
    //    _giftView.qmui_shouldShowDebugColor = YES;
    
    //http://oqul5sf2n.bkt.clouddn.com/d0eaa7fa-dfeb-4621-ac6d-6ddf27afac46
    
    labtitle.text = [NSString stringWithFormat:ASLocalizedString(@"私照(%ld)"),(long)model.pictures_count];
    for(int i = 0;i<model.pictures.count;i++)
    {
        
        //'status':'1免费2收费',
        PicturesFULL *video = model.pictures[i];
        UIImageView *gimg = [[UIImageView alloc] init];
        gimg.frame = CGRectMake(giftwidth * i + spaing * i , 2, giftwidth, giftwidth);
        //        [gimg sd_setImageWithURL:[cyurl safeUrl:video.img] placeholderImage:emptyimage];
        [gimg sd_setImageWithURL:[cyurl safeUrl:video.img] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            //            if(video.status == 2)
            //            {
            //                gimg.image = [image imageByBlurSoft];
            //            }
        }];
        
        [_giftView addSubview:gimg];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end

